#!/usr/bin/env python
# encoding: utf-8
"""
__init__.py

Created by 黄 冬 on 2007-12-12.
Copyright (c) 2007 __MyCompanyName__. All rights reserved.
"""

TABLE_BIND = dict(command_id=1,command_name='table_bind',body_fmt='!6s16sH10s',body_dynamic=False)
TABLE_BIND_RESP = dict(command_id=2,command_name='table_bind_resp',body_fmt='!HH',body_dynamic=False)
TABLE_UNBIND = dict(command_id=3,command_name='table_unbind',body_fmt='',body_dynamic=False)
TABLE_UNBIND_RESP = dict(command_id=4,command_name='table_unbind_resp',body_fmt='',body_dynamic=False)
TABLE_ACTIVE_TEST = dict(command_id=5,command_name='table_active_test',body_fmt='',body_dynamic=False)
TABLE_ACTIVE_TEST_RESP = dict(command_id=6,command_name='table_active_test_resp',body_fmt='',body_dynamic=False)
TABLE_SET = dict(command_id=7,command_name='table_set',body_fmt='''!H%(name_len)ss%(value_len)ss''',body_dynamic=True)
TABLE_SET_RESP = dict(command_id=8,command_name='table_set_resp',body_fmt='!H',body_dynamic=False)
TABLE_APPEND = dict(command_id=9,command_name='table_append',body_fmt='''!H%(name_len)ss%(value_len)ss''',body_dynamic=True)
TABLE_APPEND_RESP = dict(command_id=10,command_name='table_append_resp',body_fmt='!H',body_dynamic=False)
TABLE_DEL = dict(command_id=11,command_name='table_del',body_fmt='''%(name_len)ss''',body_dynamic=True)
TABLE_DEL_RESP = dict(command_id=12,command_name='table_del_resp',body_fmt='''!H%(name_len)ss''',body_dynamic=True)
TABLE_GET = dict(command_id=13,command_name='table_get',body_fmt='''!%(name_len)ss''',body_dynamic=True)
TABLE_GET_RESP = dict(command_id=14,command_name='table_get_resp',body_fmt='''!HH%(name_len)ss%(value_len)ss''',body_dynamic=True)

TABLE_COMMAND = {
1:TABLE_BIND,
2:TABLE_BIND_RESP,
3:TABLE_UNBIND,
4:TABLE_UNBIND_RESP,
5:TABLE_ACTIVE_TEST,
6:TABLE_ACTIVE_TEST_RESP,
7:TABLE_SET,
8:TABLE_SET_RESP,
9:TABLE_APPEND,
10:TABLE_APPEND_RESP,
11:TABLE_DEL,
12:TABLE_DEL_RESP,
13:TABLE_GET,
14:TABLE_GET_RESP
}

TABLE_SERVER_IP='10.217.24.57'
TABLE_SERVER_PORT=51206

TABLE_VERSION=1
TABLE_WIN_MAX=16

TABLE_USERNAME='hd'
TABLE_PASSWORD='hd'

class SequenceID(object):
    id = 0
    """用于保存和生成sequence id"""
    def __init__(self):
        if SequenceID.id == 65535:
            SequenceID.id = 0
        SequenceID.id+=1

    def get_sequence_id(self):
        return SequenceID.id

def get_sequence_id():
    sid = SequenceID()
    return sid.get_sequence_id()

TABLE_USER={
'hd':'hd'
}
